//! Copyright 2012 Xicut Technology, Inc.
//! All rights reserved
//!
#ifndef __SensorCheck_h__
#define __SensorCheck_h__

#include "BasicTypes.h"
#include "SysTick.h"


class cSensorCheck
{
public:
    bool Pin;
    bool PinChange;

private:
    cSysTick Debounce;

public:
    inline void InitReset(bool curPin)
    {
        Pin = curPin;
        PinChange = false;
    }

    inline void SetTimeDebounce(U32 iTimeDebounce)
    {
        Debounce.SetTimeout(iTimeDebounce);
    }

    inline void CheckChange(bool curPin)
    {
        if (Pin != curPin)
        {
            if (true == Debounce.CheckTimeOut())
            {
                Pin = curPin;
                PinChange = true;
            }
        }
        else
        {
            Debounce.ResetTimeBase();
        }
    }
};

#endif // __SensorCheck_h__
